/*
   FieldVis - A Tool for Visualizing Astrophysical Magnetohydrodynamic Flow
   
   Copyright (C) 2006 - 2008     FieldVis Development Team
  
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
  
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
  
   You should have received a copy of the GNU General Public License along
   with this program; if not, write to the Free Software Foundation, Inc.,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

   File        : Matrix4x4.h
   Author      : Jeremy Moc  (mocj@msi.umn.edu)

   Description : 
*/

#ifndef MATRIX4X4_H
#define MATRIX4X4_H

#include "Vector3D.h"

// 4x4 homogeneous transformation matrix using OpenGL alignment.
//   0   4   8   12
//   1   5   9   13
//   2   6  10   14
//   3   7  11   15
struct Matrix4x4
{
   double Elems[16];
};

// returns the distance from the point to the plane along the given ray
// assumes vectors are normalized
double GetLinePlaneIntersectDist(Vector3D  &TestPt, Vector3D const &RayVect,
                                 Vector3D const &PlanePt, Vector3D  &PlaneVect);

// returns the 4x4 rotation matrix for the given axis and angle
// assumes axis is normalized
Matrix4x4 CalcRotMat(Vector3D const &Axis, double Angle);

// applies complete transformation (rotation plus translation) defined by matrix
//   to point
Vector3D TransformPoint(Vector3D const &P, Matrix4x4 const &M);

// applies only rotation component of transformation defined by matrix to vector
Vector3D TransformVector(Vector3D const &V, Matrix4x4 const &M);

#endif
